package com.lac.component.service.impl;

import com.lac.component.dao.UserRepository;
import com.lac.component.model.User;
import com.lac.component.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Optional;

/**
 * @author xiaokuixiao
 * date2025/7/15 11:14
 */
@Service(value = "UserService")
public class UserServiceImpl  implements UserService {
    @Autowired
    private UserRepository userRepository;

    public User saveUser() {
        User user = new User();
        user.setName("张三");
        user.setAge(25);
        User save = userRepository.save(user);
        return save;
    }

    @Override
    public User selectUser() {
        Optional<User> byId = userRepository.findById("6LF_DJgB0PFrxnZYba5t");
        return byId.orElse(null);
    }
}
